package com.bj58.mis.bigdata.mdp.sys.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonUtil {
    private static Gson gson = buildGson();

    private static Gson buildGson(){
        GsonBuilder gsonBuilder = new GsonBuilder();
        gsonBuilder.setDateFormat("yyyy-MM-dd HH:mm:ss");
        return gsonBuilder.disableHtmlEscaping().create();
    }

    public static String toJson(Object obj){
        return gson.toJson(obj);
    }
    public static <T> T fromJson(String json, Class<T> clazz){
        return gson.fromJson(json, clazz);
    }
}